package util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.LogManager;
import java.util.logging.Logger;

/**
 * This is an assistant class to survey activities of the application using the 
 * java.util.logging package. 
 * 
 *@see Logger
 *@see LogManager
 * @author Kristin Behrens, Robin Gawenda, Swen Jung
 */
public abstract class MyLogger
{
	/**
	 * The {@link Logger} for the calling class.
	 */
	protected static Logger log;
	
	/**
	 * The name of the class this logger logs for.
	 */
	protected static String sourceClass;
	
	/**
	 * Constructor for the MyLogger class. 
	 */
	public MyLogger()
	{
		sourceClass = this.getClass().getName();
		log = Logger.getLogger(sourceClass);
	}
	
	/**
	 * Loads the global application settings for {@link Logger} from the file
	 * <i>config/logging.properties</i>
	 * @throws SecurityException
	 * @throws FileNotFoundException
	 * @throws IOException
	 */
	public static void loadLoggerSettings()  
	{
		LogManager logMan = LogManager.getLogManager();
		try {
			File f=new File("."+File.separator+"config"+File.separator+"logging.properties");
			System.out.println(f.getAbsolutePath());
			logMan.readConfiguration(new FileInputStream(f));
		} catch (Exception e) {
			
			e.printStackTrace();
		}
	}
}
